
using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using GruntXProductions;
using Viper;
using Viper.Opcodes;

namespace Diamond
{
    public partial class CodeGen
    {
		public OperatorOverload getOverload(Operator op, string Type)
		{
			foreach(SyntaxNode sn in this.AST)
			{
				if(sn is OperatorOverload)
				{
					OperatorOverload oo = sn as OperatorOverload;
					
					if(GetTypeName(GuessType(op.Op1)) == oo.Arguments[0].Type && GetTypeName(GuessType(op.Op2)) == oo.Arguments[1].Type && Type == oo.Type && oo.theOperator == op.theOperator)
						return oo;
				}
			}
			return null;
		}
        public bool isOverloaded(Operator op, string Type)
		{
			foreach(SyntaxNode sn in this.AST)
			{
				if(sn is OperatorOverload)
				{
					OperatorOverload oo = sn as OperatorOverload;
					
					if(GetTypeName(GuessType(op.Op1)) == oo.Arguments[0].Type && GetTypeName(GuessType(op.Op2)) == oo.Arguments[1].Type && Type == oo.Type && oo.theOperator == op.theOperator)
						return true;
				}
			}
			return false;
        }
    }

}